package com.woniuxy.dao;

import com.woniuxy.entity.OperationLog;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;
@Mapper
public interface OperationLogMapper {
    /**
     * 查询1页数据
     */
//    @Select("select * from operation_log limit #{begin}, #{size}")
//    List<OperationLog> findPage(@Param("begin") int begin, @Param("size") int size);

    /**
     * 查询总记录数
     */
    @Select(" select count(*) from operation_log")
    int count();


    /**
     *添加日志
     */
    @Insert("insert into operation_log values(null,#{methodName},#{methodParams},#{executionTime},#{result},#{logTime})")
    int save(OperationLog operationLog);
    /**
     * 通过名字查询
     */
    @Select("SELECT id,method_name,method_params,execution_time,result,log_time from operation_log WHERE method_name = #{methodName}")
    OperationLog findByName(String methodName);

    /**
     * 多条件查询一页数据
     * @param condition 封装多个查询条件
     */
    List<OperationLog> findByCondition(Map<String, Object> condition);
    /**
     * 查询符合条件的总数据
     * @param condition 封装多个查询条件
     */
    long countByCondition(@Param("condition") Map<String,Object> condition);

    /**
     * 批量删除
     *
     */
    int deleteBatch(@Param("ids") String[] ids);
}
